package com.hzjq.fxlib.presenter

import android.graphics.drawable.GradientDrawable
import android.view.KeyEvent
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import com.hzjq.fxlib.R
import com.hzjq.fxlib.event.UploadEvent
import com.wxl.common.util.DPUtil
import kotlinx.android.synthetic.main.layout_blast_finish.view.*
import org.greenrobot.eventbus.EventBus

class BlastFinishPresenter : AbsViewPresenter {

    constructor(rootView: ViewGroup) : super(rootView)

    override fun onContentViewId(): Int {
        return R.layout.layout_blast_finish
    }

    override fun onResume() {
        rootView.blastUpload.setOnClickListener {
            EventBus.getDefault().post(UploadEvent())
            finish()
        }
        (rootView.blastFinishLayout.background as GradientDrawable).setColor(ContextCompat.getColor(getContext(),android.R.color.holo_green_dark))
        (rootView.blastFinishLineView.background as GradientDrawable).setStroke(DPUtil.dip2px(2),ContextCompat.getColor(getContext(),android.R.color.holo_green_dark))
    }

    override fun showAction(action: String) {

    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if(keyCode == KeyEvent.KEYCODE_F2){
            rootView.blastUpload.performClick()
            return true
        }
        return super.onKeyDown(keyCode, event)
    }
}